package com.demo.controller.setting;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.demo.dao.Result;
import com.demo.pojo.setting.ProcessTemplate;
import com.demo.service.setting.ProcessTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/processSet/template")
public class ProcessTemplateController {
    @Autowired
    private ProcessTemplateService processTemplateService;

    @PostMapping
    public Result addTemplate(@RequestBody ProcessTemplate processTemplate) {
        processTemplateService.save(processTemplate);
        return Result.success();
    }
    @GetMapping
    public Result<Page<ProcessTemplate>> getTemplate(int pageNum, int pageSize) {
        Page<ProcessTemplate> page = processTemplateService.lambdaQuery().page(Page.of(pageNum, pageSize));
        return Result.success(page);
    }
    @DeleteMapping
    public Result deleteTemplate(@RequestParam int id) {
        processTemplateService.removeById(id);
        return Result.success();
    }
}
